package Levels;

import org.andengine.entity.scene.background.Background;

import Parts.HexagonTile;
import Parts.Player;
import Parts.HexagonTile.HexagonState;
import Units.*;
import Utils.Array;
import Utils.Vector2;
import nl.hro.mgdd.team4.raidersofhexagoniland.Scenes.LevelBaseScene;
import nl.hro.mgdd.team4.raidersofhexagoniland.Scenes.SceneManager;

public class W1Level1 extends LevelBaseScene {

	public W1Level1() {
		SceneManager._player = new Player(2, 2, 2);
		_origin = new Vector2(0f, 22f);
		_map = new HexagonTile[3][2];
		_map[0][0] = new HexagonTile(new Vector2(0, 0), HexagonState.StartTile,
				null, 0);
		_map[1][1] = new HexagonTile(new Vector2(1, 1), HexagonState.Occupied,
				new Array<Unit>(new Unit[] { new Archer(),
						new Swordman(), new Spearman() }), 12);
		_map[1][0] = new HexagonTile(new Vector2(1, 0), HexagonState.Occupied,
				new Array<Unit>(new Unit[] { new Archer(),
						new Swordman(), new Spearman() }), 11);
		_map[2][1] = new HexagonTile(new Vector2(2, 1),
				HexagonState.FinishTile, null, 22);

		int eSword = 0;
		int eSpear = 0;
		int eBow = 0;
		for (int x = 0; x < getMapWidth(); x++)
			for (int y = 0; y < getMapHeight(); y++)
				if (_map[x][y] != null) {
					if (_map[x][y].getUnitCount() != 0) {
						for (Unit u : _map[x][y].getUnits()) {
							if (u.getTag() == 999)
								eBow++;
							if (u.getTag() == 998)
								eSpear++;
							if (u.getTag() == 997)
								eSword++;
						}
					}
					_tiles.add(_map[x][y]);
				}

		SceneManager._enemy = new Player(eSword, eBow, eSpear);

		setBackground(new Background(0.5f, 0.5f, 0.5f));
		loadResources();
	}

	@Override
	public int getMapWidth() {
		return 3;
	}

	@Override
	public int getMapHeight() {
		return 2;
	}
}
